package com.shop.user.controller;

import com.shop.entity.dto.WeChatCart.UserCartRemoveDto;
import com.shop.entity.dto.WeChatCart.UserCartSaveDto;
import com.shop.entity.dto.WeChatCart.UserCartUpdateNumDto;
import com.shop.entity.vo.CartVo;
import com.shop.user.service.CartService;
import com.shop.utils.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cart")

public class CartController {

    @Autowired
    private CartService cartService;

    @PostMapping("save_cart")
    public Result addCart(@RequestBody UserCartSaveDto dto){
        return cartService.addCart(dto);
    }

    @GetMapping("get_cart")
    public Result<List<CartVo>> getCart(){
        return cartService.getCart();
    }

    @PostMapping("upd_number")
    public Result upNum(@RequestBody UserCartUpdateNumDto dto){
        return cartService.updateCartNum(dto);
    }

    @PostMapping("del_cart")
    public Result delOneCart(@RequestBody UserCartRemoveDto dto){
        return cartService.delCart(dto);
    }

}
